﻿<Window x:Class="ProjectBilling.UI.WPF.ProjectsView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Projects" MinHeight="180" Height="180"
        MinWidth="250" Width="250" Padding="5"
        FocusManager.FocusedElement
            ="{Binding ElementName=ProjectsComboBox}">
    <Window.Resources>
        <!-- Update estimate color -->
        <Style x:Key="EstimateStyle"
                TargetType="{x:Type TextBox}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding 
                            DetailsEstimateStatus}"
                        Value="None">
                    <Setter Property="Foreground"
                            Value="Black" />
                </DataTrigger>
                <DataTrigger Binding="{Binding 
                            DetailsEstimateStatus}"
                        Value="Good">
                    <Setter Property="Foreground"
                            Value="Green" />
                </DataTrigger>
                <DataTrigger Binding="{Binding 
                            DetailsEstimateStatus}"
                        Value="Bad">
                    <Setter Property="Foreground" Value="Red" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <Label Content="Project:" />
        <ComboBox Margin="5" Grid.Column="1" 
                SelectedValue="{Binding Path=SelectedValue, 
                    Mode=OneWayToSource}"
                ItemsSource="{Binding Path=Projects}"
                DisplayMemberPath="Name"
                SelectedValuePath="ID" />
        <Label Content="Estimated Cost:" Grid.Row="1" />
        <TextBox Margin="5" Grid.Row="1" Grid.Column="1"
                IsEnabled="{Binding Path=DetailsEnabled}" 
                Text="{Binding Path=SelectedProject.Estimate}" 
                Style="{StaticResource EstimateStyle}" />
        <Label Content="Actual Cost:" Grid.Row="2" />
        <TextBox Margin="5" Grid.Row="2"  Grid.Column="1" 
                IsEnabled="{Binding Path=DetailsEnabled}" 
                Text="{Binding Path=SelectedProject.Actual}" />
        <Button Content="Update" Margin="5" Grid.Row="3"
                Grid.ColumnSpan="2"
                Command="{Binding Path=UpdateCommand}" />
    </Grid>
</Window>
